#include<iostream>
#include<unistd.h>
#include<functional>
#include<vector>
#include<signal.h>
#include<sys/types.h>
//方法
//=========================================================================
void Sched()
{
    std::cout << "我是进程调度" << std::endl;
}
void Memmanger()
{
    std::cout << "我是内存管理,检查内存问题" << std::endl;
}
void Flush()
{
    std::cout << "我是刷新程序,定期刷新数据" << std::endl;
}
//=========================================================================
using func_t = std::function<void()>;
std::vector<func_t> v1;
int count = 5;
void handlersig(int sig)
{
    std::cout << "###############################" << std::endl;
    for(auto x : v1)
    {
        x();
    }
    std::cout << "开机时间: " << count++ << std::endl; 
    std::cout << "###############################" << std::endl;
    alarm(1);
}
int main()
{
    v1.push_back(Sched);
    v1.push_back(Memmanger);
    v1.push_back(Flush);
    signal(SIGALRM,handlersig);
    alarm(5);
    while(true)//操作系统也是牛马,也需要外界的刺激才会工作
    {
        pause();
    }
    return 0;
}